<?php

class LogTool {/* {{{ */

    static $_requestdata_log   = null;
    static $_mysqlerror_log    = null;
    static $_mysqllog_log      = null;
    static $_errorlog_log      = null;
    static $_responsesucc_log  = null;
    static $_responseerror_log = null;
    static $_loginvaldata_log  = null;
    static $_messagedata_log   = null;

    public static function errorlogLog ()
    {/* {{{ */
        return self::getLogTpl ( 'errorlog' );
    }

/* }}} */

    public static function requestdataLog ()
    {/* {{{ */
        return self::getLogTpl ( 'requestdata' );
    }

/* }}} */

    public static function loginvaldataLog ()
    {
        return self::getLogTpl ( 'loginvaldata' );
    }

    public static function mysqlerrorLog ()
    {/* {{{ */
        return self::getLogTpl ( 'mysqlerror' );
    }

/* }}} */

    public static function mysqllogLog ()
    {/* {{{ */
        return self::getLogTpl ( 'mysqllog' );
    }

/* }}} */

    public static function responsesuccLog ()
    {/* {{{ */
        return self::getLogTpl ( 'responsesucc' );
    }

/* }}} */

    public static function responseerrorLog ()
    {/* {{{ */
        return self::getLogTpl ( 'responseerror' );
    }
    
    public static function meaasgedataLog ()
    {/* {{{ */
        return self::getLogTpl ( 'messagedata' );
    }

/* }}} */

    private static function getLogTpl ($type , $only = false)
    {/* {{{ */
        $config   = Yaf_Registry::get ( "config" )->application->log->toArray ();
        $obj_name = '_' . $type . '_log';
        if ( is_object ( self::$$obj_name ) )
        {
            return self::$$obj_name;
        }
        $dname           = $config[ 'path' ] . $type;
        $fname           = $only ? $type . '.log' : $type . '_' . date ( 'Ymd' ) . '.log';
        $filename        = $dname . '/' . $fname;
        self::$$obj_name = new Tools_LogObject ( $dname , $filename );
        return self::$$obj_name;
    }

/* }}} */
}

/* }}} */
?>